package com.zzj.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zzj.bean.UserBean;
import com.zzj.dao.UserDao;
import com.zzj.utils.Result;
import com.zzj.utils.StatusCode;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao userDao;

    @Override
    public PageInfo<UserBean> getAllUsers(int pageNum,int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<UserBean> users = userDao.getUsers();
        return new PageInfo<>(users);
    }

    @Override
    public Result updateStateById(int uid, String ustate) {
        int i = userDao.updateStateById(uid, ustate);
        if (i == 1){
            return new Result();
        }
        return new Result(false, StatusCode.ERROR,"");
    }
}
